home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-4.z / lispref.info-4
Encoding:
GNU Info File  |  1998-05-21  |  49.0 KB  |  1,438 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Font Instance Type,  Next: Color Instance Type,  Prev: Specifier Type,  Up: Window-System Types
  48.  
  49. Font Instance Type
  50. ------------------
  51.  
  52.    (not yet documented)
  53.  
  54. 
  55. File: lispref.info,  Node: Color Instance Type,  Next: Image Instance Type,  Prev: Font Instance Type,  Up: Window-System Types
  56.  
  57. Color Instance Type
  58. -------------------
  59.  
  60.    (not yet documented)
  61.  
  62. 
  63. File: lispref.info,  Node: Image Instance Type,  Next: Toolbar Button Type,  Prev: Color Instance Type,  Up: Window-System Types
  64.  
  65. Image Instance Type
  66. -------------------
  67.  
  68.    (not yet documented)
  69.  
  70. 
  71. File: lispref.info,  Node: Toolbar Button Type,  Next: Subwindow Type,  Prev: Image Instance Type,  Up: Window-System Types
  72.  
  73. Toolbar Button Type
  74. -------------------
  75.  
  76.    (not yet documented)
  77.  
  78. 
  79. File: lispref.info,  Node: Subwindow Type,  Next: X Resource Type,  Prev: Toolbar Button Type,  Up: Window-System Types
  80.  
  81. Subwindow Type
  82. --------------
  83.  
  84.    (not yet documented)
  85.  
  86. 
  87. File: lispref.info,  Node: X Resource Type,  Prev: Subwindow Type,  Up: Window-System Types
  88.  
  89. X Resource Type
  90. ---------------
  91.  
  92.    (not yet documented)
  93.  
  94. 
  95. File: lispref.info,  Node: Type Predicates,  Next: Equality Predicates,  Prev: Window-System Types,  Up: Lisp Data Types
  96.  
  97. Type Predicates
  98. ===============
  99.  
  100.    The XEmacs Lisp interpreter itself does not perform type checking on
  101. the actual arguments passed to functions when they are called.  It could
  102. not do so, since function arguments in Lisp do not have declared data
  103. types, as they do in other programming languages.  It is therefore up to
  104. the individual function to test whether each actual argument belongs to
  105. a type that the function can use.
  106.  
  107.    All built-in functions do check the types of their actual arguments
  108. when appropriate, and signal a `wrong-type-argument' error if an
  109. argument is of the wrong type.  For example, here is what happens if you
  110. pass an argument to `+' that it cannot handle:
  111.  
  112.      (+ 2 'a)
  113.           error--> Wrong type argument: integer-or-marker-p, a
  114.  
  115.    If you want your program to handle different types differently, you
  116. must do explicit type checking.  The most common way to check the type
  117. of an object is to call a "type predicate" function.  Emacs has a type
  118. predicate for each type, as well as some predicates for combinations of
  119. types.
  120.  
  121.    A type predicate function takes one argument; it returns `t' if the
  122. argument belongs to the appropriate type, and `nil' otherwise.
  123. Following a general Lisp convention for predicate functions, most type
  124. predicates' names end with `p'.
  125.  
  126.    Here is an example which uses the predicates `listp' to check for a
  127. list and `symbolp' to check for a symbol.
  128.  
  129.      (defun add-on (x)
  130.        (cond ((symbolp x)
  131.               ;; If X is a symbol, put it on LIST.
  132.               (setq list (cons x list)))
  133.              ((listp x)
  134.               ;; If X is a list, add its elements to LIST.
  135.               (setq list (append x list)))
  136.              (t
  137.               ;; We only handle symbols and lists.
  138.               (error "Invalid argument %s in add-on" x))))
  139.  
  140.    Here is a table of predefined type predicates, in alphabetical order,
  141. with references to further information.
  142.  
  143. `annotationp'
  144.      *Note annotationp: Annotation Primitives.
  145.  
  146. `arrayp'
  147.      *Note arrayp: Array Functions.
  148.  
  149. `atom'
  150.      *Note atom: List-related Predicates.
  151.  
  152. `bit-vector-p'
  153.      *Note bit-vector-p: Bit Vector Functions.
  154.  
  155. `bitp'
  156.      *Note bitp: Bit Vector Functions.
  157.  
  158. `boolean-specifier-p'
  159.      *Note boolean-specifier-p: Specifier Types.
  160.  
  161. `buffer-glyph-p'
  162.      *Note buffer-glyph-p: Glyph Types.
  163.  
  164. `buffer-live-p'
  165.      *Note buffer-live-p: Killing Buffers.
  166.  
  167. `bufferp'
  168.      *Note bufferp: Buffer Basics.
  169.  
  170. `button-event-p'
  171.      *Note button-event-p: Event Predicates.
  172.  
  173. `button-press-event-p'
  174.      *Note button-press-event-p: Event Predicates.
  175.  
  176. `button-release-event-p'
  177.      *Note button-release-event-p: Event Predicates.
  178.  
  179. `case-table-p'
  180.      *Note case-table-p: Case Tables.
  181.  
  182. `char-int-p'
  183.      *Note char-int-p: Character Codes.
  184.  
  185. `char-or-char-int-p'
  186.      *Note char-or-char-int-p: Character Codes.
  187.  
  188. `char-or-string-p'
  189.      *Note char-or-string-p: Predicates for Strings.
  190.  
  191. `char-table-p'
  192.      *Note char-table-p: Char Tables.
  193.  
  194. `characterp'
  195.      *Note characterp: Predicates for Characters.
  196.  
  197. `color-instance-p'
  198.      *Note color-instance-p: Colors.
  199.  
  200. `color-pixmap-image-instance-p'
  201.      *Note color-pixmap-image-instance-p: Image Instance Types.
  202.  
  203. `color-specifier-p'
  204.      *Note color-specifier-p: Specifier Types.
  205.  
  206. `commandp'
  207.      *Note commandp: Interactive Call.
  208.  
  209. `compiled-function-p'
  210.      *Note compiled-function-p: Compiled-Function Type.
  211.  
  212. `console-live-p'
  213.      *Note console-live-p: Connecting to a Console or Device.
  214.  
  215. `consolep'
  216.      *Note consolep: Consoles and Devices.
  217.  
  218. `consp'
  219.      *Note consp: List-related Predicates.
  220.  
  221. `database-live-p'
  222.      *Note database-live-p: Connecting to a Database.
  223.  
  224. `databasep'
  225.      *Note databasep: Databases.
  226.  
  227. `device-live-p'
  228.      *Note device-live-p: Connecting to a Console or Device.
  229.  
  230. `device-or-frame-p'
  231.      *Note device-or-frame-p: Basic Device Functions.
  232.  
  233. `devicep'
  234.      *Note devicep: Consoles and Devices.
  235.  
  236. `eval-event-p'
  237.      *Note eval-event-p: Event Predicates.
  238.  
  239. `event-live-p'
  240.      *Note event-live-p: Event Predicates.
  241.  
  242. `eventp'
  243.      *Note eventp: Events.
  244.  
  245. `extent-live-p'
  246.      *Note extent-live-p: Creating and Modifying Extents.
  247.  
  248. `extentp'
  249.      *Note extentp: Extents.
  250.  
  251. `face-boolean-specifier-p'
  252.      *Note face-boolean-specifier-p: Specifier Types.
  253.  
  254. `facep'
  255.      *Note facep: Basic Face Functions.
  256.  
  257. `floatp'
  258.      *Note floatp: Predicates on Numbers.
  259.  
  260. `font-instance-p'
  261.      *Note font-instance-p: Fonts.
  262.  
  263. `font-specifier-p'
  264.      *Note font-specifier-p: Specifier Types.
  265.  
  266. `frame-live-p'
  267.      *Note frame-live-p: Deleting Frames.
  268.  
  269. `framep'
  270.      *Note framep: Frames.
  271.  
  272. `functionp'
  273.      (not yet documented)
  274.  
  275. `generic-specifier-p'
  276.      *Note generic-specifier-p: Specifier Types.
  277.  
  278. `glyphp'
  279.      *Note glyphp: Glyphs.
  280.  
  281. `hashtablep'
  282.      *Note hashtablep: Hash Tables.
  283.  
  284. `icon-glyph-p'
  285.      *Note icon-glyph-p: Glyph Types.
  286.  
  287. `image-instance-p'
  288.      *Note image-instance-p: Images.
  289.  
  290. `image-specifier-p'
  291.      *Note image-specifier-p: Specifier Types.
  292.  
  293. `integer-char-or-marker-p'
  294.      *Note integer-char-or-marker-p: Predicates on Markers.
  295.  
  296. `integer-or-char-p'
  297.      *Note integer-or-char-p: Predicates for Characters.
  298.  
  299. `integer-or-marker-p'
  300.      *Note integer-or-marker-p: Predicates on Markers.
  301.  
  302. `integer-specifier-p'
  303.      *Note integer-specifier-p: Specifier Types.
  304.  
  305. `integerp'
  306.      *Note integerp: Predicates on Numbers.
  307.  
  308. `itimerp'
  309.      (not yet documented)
  310.  
  311. `key-press-event-p'
  312.      *Note key-press-event-p: Event Predicates.
  313.  
  314. `keymapp'
  315.      *Note keymapp: Creating Keymaps.
  316.  
  317. `keywordp'
  318.      (not yet documented)
  319.  
  320. `listp'
  321.      *Note listp: List-related Predicates.
  322.  
  323. `markerp'
  324.      *Note markerp: Predicates on Markers.
  325.  
  326. `misc-user-event-p'
  327.      *Note misc-user-event-p: Event Predicates.
  328.  
  329. `mono-pixmap-image-instance-p'
  330.      *Note mono-pixmap-image-instance-p: Image Instance Types.
  331.  
  332. `motion-event-p'
  333.      *Note motion-event-p: Event Predicates.
  334.  
  335. `mouse-event-p'
  336.      *Note mouse-event-p: Event Predicates.
  337.  
  338. `natnum-specifier-p'
  339.      *Note natnum-specifier-p: Specifier Types.
  340.  
  341. `natnump'
  342.      *Note natnump: Predicates on Numbers.
  343.  
  344. `nlistp'
  345.      *Note nlistp: List-related Predicates.
  346.  
  347. `nothing-image-instance-p'
  348.      *Note nothing-image-instance-p: Image Instance Types.
  349.  
  350. `number-char-or-marker-p'
  351.      *Note number-char-or-marker-p: Predicates on Markers.
  352.  
  353. `number-or-marker-p'
  354.      *Note number-or-marker-p: Predicates on Markers.
  355.  
  356. `numberp'
  357.      *Note numberp: Predicates on Numbers.
  358.  
  359. `pointer-glyph-p'
  360.      *Note pointer-glyph-p: Glyph Types.
  361.  
  362. `pointer-image-instance-p'
  363.      *Note pointer-image-instance-p: Image Instance Types.
  364.  
  365. `process-event-p'
  366.      *Note process-event-p: Event Predicates.
  367.  
  368. `processp'
  369.      *Note processp: Processes.
  370.  
  371. `range-table-p'
  372.      *Note range-table-p: Range Tables.
  373.  
  374. `ringp'
  375.      (not yet documented)
  376.  
  377. `sequencep'
  378.      *Note sequencep: Sequence Functions.
  379.  
  380. `specifierp'
  381.      *Note specifierp: Specifiers.
  382.  
  383. `stringp'
  384.      *Note stringp: Predicates for Strings.
  385.  
  386. `subrp'
  387.      *Note subrp: Function Cells.
  388.  
  389. `subwindow-image-instance-p'
  390.      *Note subwindow-image-instance-p: Image Instance Types.
  391.  
  392. `subwindowp'
  393.      *Note subwindowp: Subwindows.
  394.  
  395. `symbolp'
  396.      *Note symbolp: Symbols.
  397.  
  398. `syntax-table-p'
  399.      *Note syntax-table-p: Syntax Tables.
  400.  
  401. `text-image-instance-p'
  402.      *Note text-image-instance-p: Image Instance Types.
  403.  
  404. `timeout-event-p'
  405.      *Note timeout-event-p: Event Predicates.
  406.  
  407. `toolbar-button-p'
  408.      *Note toolbar-button-p: Toolbar.
  409.  
  410. `toolbar-specifier-p'
  411.      *Note toolbar-specifier-p: Toolbar.
  412.  
  413. `user-variable-p'
  414.      *Note user-variable-p: Defining Variables.
  415.  
  416. `vectorp'
  417.      *Note vectorp: Vectors.
  418.  
  419. `weak-list-p'
  420.      *Note weak-list-p: Weak Lists.
  421.  
  422. `window-configuration-p'
  423.      *Note window-configuration-p: Window Configurations.
  424.  
  425. `window-live-p'
  426.      *Note window-live-p: Deleting Windows.
  427.  
  428. `windowp'
  429.      *Note windowp: Basic Windows.
  430.  
  431.    The most general way to check the type of an object is to call the
  432. function `type-of'.  Recall that each object belongs to one and only
  433. one primitive type; `type-of' tells you which one (*note Lisp Data
  434. Types::.).  But `type-of' knows nothing about non-primitive types.  In
  435. most cases, it is more convenient to use type predicates than `type-of'.
  436.  
  437.  - Function: type-of OBJECT
  438.      This function returns a symbol naming the primitive type of
  439.      OBJECT.  The value is one of `bit-vector', `buffer', `char-table',
  440.      `character', `charset', `coding-system', `cons', `color-instance',
  441.      `compiled-function', `console', `database', `device', `event',
  442.      `extent', `face', `float', `font-instance', `frame', `glyph',
  443.      `hashtable', `image-instance', `integer', `keymap', `marker',
  444.      `process', `range-table', `specifier', `string', `subr',
  445.      `subwindow', `symbol', `toolbar-button', `tooltalk-message',
  446.      `tooltalk-pattern', `vector', `weak-list', `window',
  447.      `window-configuration', or `x-resource'.
  448.  
  449.           (type-of 1)
  450.                => integer
  451.           (type-of 'nil)
  452.                => symbol
  453.           (type-of '())    ; `()' is `nil'.
  454.                => symbol
  455.           (type-of '(x))
  456.                => cons
  457.  
  458. 
  459. File: lispref.info,  Node: Equality Predicates,  Prev: Type Predicates,  Up: Lisp Data Types
  460.  
  461. Equality Predicates
  462. ===================
  463.  
  464.    Here we describe two functions that test for equality between any two
  465. objects.  Other functions test equality between objects of specific
  466. types, e.g., strings.  For these predicates, see the appropriate chapter
  467. describing the data type.
  468.  
  469.  - Function: eq OBJECT1 OBJECT2
  470.      This function returns `t' if OBJECT1 and OBJECT2 are the same
  471.      object, `nil' otherwise.  The "same object" means that a change in
  472.      one will be reflected by the same change in the other.
  473.  
  474.      `eq' returns `t' if OBJECT1 and OBJECT2 are integers with the same
  475.      value.  Also, since symbol names are normally unique, if the
  476.      arguments are symbols with the same name, they are `eq'.  For
  477.      other types (e.g., lists, vectors, strings), two arguments with
  478.      the same contents or elements are not necessarily `eq' to each
  479.      other: they are `eq' only if they are the same object.
  480.  
  481.      (The `make-symbol' function returns an uninterned symbol that is
  482.      not interned in the standard `obarray'.  When uninterned symbols
  483.      are in use, symbol names are no longer unique.  Distinct symbols
  484.      with the same name are not `eq'.  *Note Creating Symbols::.)
  485.  
  486.      NOTE: Under XEmacs 19, characters are really just integers, and
  487.      thus characters and integers are `eq'.  Under XEmacs 20, it was
  488.      necessary to preserve remants of this in function such as `old-eq'
  489.      in order to maintain byte-code compatibility.  Byte code compiled
  490.      under any Emacs 19 will automatically have calls to `eq' mapped to
  491.      `old-eq' when executed under XEmacs 20.
  492.  
  493.           (eq 'foo 'foo)
  494.                => t
  495.           
  496.           (eq 456 456)
  497.                => t
  498.           
  499.           (eq "asdf" "asdf")
  500.                => nil
  501.           
  502.           (eq '(1 (2 (3))) '(1 (2 (3))))
  503.                => nil
  504.           
  505.           (setq foo '(1 (2 (3))))
  506.                => (1 (2 (3)))
  507.           (eq foo foo)
  508.                => t
  509.           (eq foo '(1 (2 (3))))
  510.                => nil
  511.           
  512.           (eq [(1 2) 3] [(1 2) 3])
  513.                => nil
  514.           
  515.           (eq (point-marker) (point-marker))
  516.                => nil
  517.  
  518.  
  519.  - Function: old-eq OBJ1 OBJ2
  520.      This function exists under XEmacs 20 and is exactly like `eq'
  521.      except that it suffers from the char-int confoundance disease.  In
  522.      other words, it returns `t' if given a character and the
  523.      equivalent integer, even though the objects are of different types!
  524.      You should *not* ever call this function explicitly in your code.
  525.      However, be aware that all calls to `eq' in byte code compiled
  526.      under version 19 map to `old-eq' in XEmacs 20.  (Likewise for
  527.      `old-equal', `old-memq', `old-member', `old-assq' and
  528.      `old-assoc'.)
  529.  
  530.           ;; Remember, this does not apply under XEmacs 19.
  531.           ?A
  532.                => ?A
  533.           (char-int ?A)
  534.                => 65
  535.           (old-eq ?A 65)
  536.                => t               ; Eek, we've been infected.
  537.           (eq ?A 65)
  538.                => nil             ; We are still healthy.
  539.  
  540.  - Function: equal OBJECT1 OBJECT2
  541.      This function returns `t' if OBJECT1 and OBJECT2 have equal
  542.      components, `nil' otherwise.  Whereas `eq' tests if its arguments
  543.      are the same object, `equal' looks inside nonidentical arguments
  544.      to see if their elements are the same.  So, if two objects are
  545.      `eq', they are `equal', but the converse is not always true.
  546.  
  547.           (equal 'foo 'foo)
  548.                => t
  549.           
  550.           (equal 456 456)
  551.                => t
  552.           
  553.           (equal "asdf" "asdf")
  554.                => t
  555.           (eq "asdf" "asdf")
  556.                => nil
  557.           
  558.           (equal '(1 (2 (3))) '(1 (2 (3))))
  559.                => t
  560.           (eq '(1 (2 (3))) '(1 (2 (3))))
  561.                => nil
  562.           
  563.           (equal [(1 2) 3] [(1 2) 3])
  564.                => t
  565.           (eq [(1 2) 3] [(1 2) 3])
  566.                => nil
  567.           
  568.           (equal (point-marker) (point-marker))
  569.                => t
  570.           
  571.           (eq (point-marker) (point-marker))
  572.                => nil
  573.  
  574.      Comparison of strings is case-sensitive.
  575.  
  576.      Note that in FSF GNU Emacs, comparison of strings takes into
  577.      account their text properties, and you have to use `string-equal'
  578.      if you want only the strings themselves compared.  This difference
  579.      does not exist in XEmacs; `equal' and `string-equal' always return
  580.      the same value on the same strings.
  581.  
  582.           (equal "asdf" "ASDF")
  583.                => nil
  584.  
  585.      Two distinct buffers are never `equal', even if their contents are
  586.      the same.
  587.  
  588.    The test for equality is implemented recursively, and circular lists
  589. may therefore cause infinite recursion (leading to an error).
  590.  
  591. 
  592. File: lispref.info,  Node: Numbers,  Next: Strings and Characters,  Prev: Lisp Data Types,  Up: Top
  593.  
  594. Numbers
  595. *******
  596.  
  597.    XEmacs supports two numeric data types: "integers" and "floating
  598. point numbers".  Integers are whole numbers such as -3, 0, 7, 13, and
  599. 511.  Their values are exact.  Floating point numbers are numbers with
  600. fractional parts, such as -4.5, 0.0, or 2.71828.  They can also be
  601. expressed in exponential notation: 1.5e2 equals 150; in this example,
  602. `e2' stands for ten to the second power, and is multiplied by 1.5.
  603. Floating point values are not exact; they have a fixed, limited amount
  604. of precision.
  605.  
  606. * Menu:
  607.  
  608. * Integer Basics::            Representation and range of integers.
  609. * Float Basics::          Representation and range of floating point.
  610. * Predicates on Numbers::     Testing for numbers.
  611. * Comparison of Numbers::     Equality and inequality predicates.
  612. * Numeric Conversions::          Converting float to integer and vice versa.
  613. * Arithmetic Operations::     How to add, subtract, multiply and divide.
  614. * Rounding Operations::       Explicitly rounding floating point numbers.
  615. * Bitwise Operations::        Logical and, or, not, shifting.
  616. * Math Functions::            Trig, exponential and logarithmic functions.
  617. * Random Numbers::            Obtaining random integers, predictable or not.
  618.  
  619. 
  620. File: lispref.info,  Node: Integer Basics,  Next: Float Basics,  Up: Numbers
  621.  
  622. Integer Basics
  623. ==============
  624.  
  625.    The range of values for an integer depends on the machine.  The
  626. minimum range is -134217728 to 134217727 (28 bits; i.e., -2**27 to
  627. 2**27 - 1), but some machines may provide a wider range.  Many examples
  628. in this chapter assume an integer has 28 bits.
  629.  
  630.    The Lisp reader reads an integer as a sequence of digits with
  631. optional initial sign and optional final period.
  632.  
  633.       1               ; The integer 1.
  634.       1.              ; The integer 1.
  635.      +1               ; Also the integer 1.
  636.      -1               ; The integer -1.
  637.       268435457       ; Also the integer 1, due to overflow.
  638.       0               ; The integer 0.
  639.      -0               ; The integer 0.
  640.  
  641.    To understand how various functions work on integers, especially the
  642. bitwise operators (*note Bitwise Operations::.), it is often helpful to
  643. view the numbers in their binary form.
  644.  
  645.    In 28-bit binary, the decimal integer 5 looks like this:
  646.  
  647.      0000  0000 0000  0000 0000  0000 0101
  648.  
  649. (We have inserted spaces between groups of 4 bits, and two spaces
  650. between groups of 8 bits, to make the binary integer easier to read.)
  651.  
  652.    The integer -1 looks like this:
  653.  
  654.      1111  1111 1111  1111 1111  1111 1111
  655.  
  656. -1 is represented as 28 ones.  (This is called "two's complement"
  657. notation.)
  658.  
  659.    The negative integer, -5, is creating by subtracting 4 from -1.  In
  660. binary, the decimal integer 4 is 100.  Consequently, -5 looks like this:
  661.  
  662.      1111  1111 1111  1111 1111  1111 1011
  663.  
  664.    In this implementation, the largest 28-bit binary integer is the
  665. decimal integer 134,217,727.  In binary, it looks like this:
  666.  
  667.      0111  1111 1111  1111 1111  1111 1111
  668.  
  669.    Since the arithmetic functions do not check whether integers go
  670. outside their range, when you add 1 to 134,217,727, the value is the
  671. negative integer -134,217,728:
  672.  
  673.      (+ 1 134217727)
  674.           => -134217728
  675.           => 1000  0000 0000  0000 0000  0000 0000
  676.  
  677.    Many of the following functions accept markers for arguments as well
  678. as integers.  (*Note Markers::.)  More precisely, the actual arguments
  679. to such functions may be either integers or markers, which is why we
  680. often give these arguments the name INT-OR-MARKER.  When the argument
  681. value is a marker, its position value is used and its buffer is ignored.
  682.  
  683. 
  684. File: lispref.info,  Node: Float Basics,  Next: Predicates on Numbers,  Prev: Integer Basics,  Up: Numbers
  685.  
  686. Floating Point Basics
  687. =====================
  688.  
  689.    XEmacs supports floating point numbers.  The precise range of
  690. floating point numbers is machine-specific; it is the same as the range
  691. of the C data type `double' on the machine in question.
  692.  
  693.    The printed representation for floating point numbers requires either
  694. a decimal point (with at least one digit following), an exponent, or
  695. both.  For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
  696. are five ways of writing a floating point number whose value is 1500.
  697. They are all equivalent.  You can also use a minus sign to write
  698. negative floating point numbers, as in `-1.0'.
  699.  
  700.    Most modern computers support the IEEE floating point standard, which
  701. provides for positive infinity and negative infinity as floating point
  702. values.  It also provides for a class of values called NaN or
  703. "not-a-number"; numerical functions return such values in cases where
  704. there is no correct answer.  For example, `(sqrt -1.0)' returns a NaN.
  705. For practical purposes, there's no significant difference between
  706. different NaN values in XEmacs Lisp, and there's no rule for precisely
  707. which NaN value should be used in a particular case, so this manual
  708. doesn't try to distinguish them.  XEmacs Lisp has no read syntax for
  709. NaNs or infinities; perhaps we should create a syntax in the future.
  710.  
  711.    You can use `logb' to extract the binary exponent of a floating
  712. point number (or estimate the logarithm of an integer):
  713.  
  714.  - Function: logb NUMBER
  715.      This function returns the binary exponent of NUMBER.  More
  716.      precisely, the value is the logarithm of NUMBER base 2, rounded
  717.      down to an integer.
  718.  
  719. 
  720. File: lispref.info,  Node: Predicates on Numbers,  Next: Comparison of Numbers,  Prev: Float Basics,  Up: Numbers
  721.  
  722. Type Predicates for Numbers
  723. ===========================
  724.  
  725.    The functions in this section test whether the argument is a number
  726. or whether it is a certain sort of number.  The functions `integerp'
  727. and `floatp' can take any type of Lisp object as argument (the
  728. predicates would not be of much use otherwise); but the `zerop'
  729. predicate requires a number as its argument.  See also
  730. `integer-or-marker-p', `integer-char-or-marker-p', `number-or-marker-p'
  731. and `number-char-or-marker-p', in *Note Predicates on Markers::.
  732.  
  733.  - Function: floatp OBJECT
  734.      This predicate tests whether its argument is a floating point
  735.      number and returns `t' if so, `nil' otherwise.
  736.  
  737.      `floatp' does not exist in Emacs versions 18 and earlier.
  738.  
  739.  - Function: integerp OBJECT
  740.      This predicate tests whether its argument is an integer, and
  741.      returns `t' if so, `nil' otherwise.
  742.  
  743.  - Function: numberp OBJECT
  744.      This predicate tests whether its argument is a number (either
  745.      integer or floating point), and returns `t' if so, `nil' otherwise.
  746.  
  747.  - Function: natnump OBJECT
  748.      The `natnump' predicate (whose name comes from the phrase
  749.      "natural-number-p") tests to see whether its argument is a
  750.      nonnegative integer, and returns `t' if so, `nil' otherwise.  0 is
  751.      considered non-negative.
  752.  
  753.  - Function: zerop NUMBER
  754.      This predicate tests whether its argument is zero, and returns `t'
  755.      if so, `nil' otherwise.  The argument must be a number.
  756.  
  757.      These two forms are equivalent: `(zerop x)' == `(= x 0)'.
  758.  
  759. 
  760. File: lispref.info,  Node: Comparison of Numbers,  Next: Numeric Conversions,  Prev: Predicates on Numbers,  Up: Numbers
  761.  
  762. Comparison of Numbers
  763. =====================
  764.  
  765.    To test numbers for numerical equality, you should normally use `=',
  766. not `eq'.  There can be many distinct floating point number objects
  767. with the same numeric value.  If you use `eq' to compare them, then you
  768. test whether two values are the same *object*.  By contrast, `='
  769. compares only the numeric values of the objects.
  770.  
  771.    At present, each integer value has a unique Lisp object in XEmacs
  772. Lisp.  Therefore, `eq' is equivalent to `=' where integers are
  773. concerned.  It is sometimes convenient to use `eq' for comparing an
  774. unknown value with an integer, because `eq' does not report an error if
  775. the unknown value is not a number--it accepts arguments of any type.
  776. By contrast, `=' signals an error if the arguments are not numbers or
  777. markers.  However, it is a good idea to use `=' if you can, even for
  778. comparing integers, just in case we change the representation of
  779. integers in a future XEmacs version.
  780.  
  781.    There is another wrinkle: because floating point arithmetic is not
  782. exact, it is often a bad idea to check for equality of two floating
  783. point values.  Usually it is better to test for approximate equality.
  784. Here's a function to do this:
  785.  
  786.      (defvar fuzz-factor 1.0e-6)
  787.      (defun approx-equal (x y)
  788.        (or (and (= x 0) (= y 0))
  789.            (< (/ (abs (- x y))
  790.                  (max (abs x) (abs y)))
  791.               fuzz-factor)))
  792.  
  793.      Common Lisp note: Comparing numbers in Common Lisp always requires
  794.      `=' because Common Lisp implements multi-word integers, and two
  795.      distinct integer objects can have the same numeric value.  XEmacs
  796.      Lisp can have just one integer object for any given value because
  797.      it has a limited range of integer values.
  798.  
  799.  - Function: = NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  800.      This function tests whether its arguments are numerically equal,
  801.      and returns `t' if so, `nil' otherwise.
  802.  
  803.  - Function: /= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  804.      This function tests whether its arguments are numerically not
  805.      equal.  It returns `t' if so, and `nil' otherwise.
  806.  
  807.  - Function: < NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  808.      This function tests whether its first argument is strictly less
  809.      than its second argument.  It returns `t' if so, `nil' otherwise.
  810.  
  811.  - Function: <= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  812.      This function tests whether its first argument is less than or
  813.      equal to its second argument.  It returns `t' if so, `nil'
  814.      otherwise.
  815.  
  816.  - Function: > NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  817.      This function tests whether its first argument is strictly greater
  818.      than its second argument.  It returns `t' if so, `nil' otherwise.
  819.  
  820.  - Function: >= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  821.      This function tests whether its first argument is greater than or
  822.      equal to its second argument.  It returns `t' if so, `nil'
  823.      otherwise.
  824.  
  825.  - Function: max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS
  826.      This function returns the largest of its arguments.
  827.  
  828.           (max 20)
  829.                => 20
  830.           (max 1 2.5)
  831.                => 2.5
  832.           (max 1 3 2.5)
  833.                => 3
  834.  
  835.  - Function: min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS
  836.      This function returns the smallest of its arguments.
  837.  
  838.           (min -4 1)
  839.                => -4
  840.  
  841. 
  842. File: lispref.info,  Node: Numeric Conversions,  Next: Arithmetic Operations,  Prev: Comparison of Numbers,  Up: Numbers
  843.  
  844. Numeric Conversions
  845. ===================
  846.  
  847.    To convert an integer to floating point, use the function `float'.
  848.  
  849.  - Function: float NUMBER
  850.      This returns NUMBER converted to floating point.  If NUMBER is
  851.      already a floating point number, `float' returns it unchanged.
  852.  
  853.    There are four functions to convert floating point numbers to
  854. integers; they differ in how they round.  These functions accept
  855. integer arguments also, and return such arguments unchanged.
  856.  
  857.  - Function: truncate NUMBER
  858.      This returns NUMBER, converted to an integer by rounding towards
  859.      zero.
  860.  
  861.  - Function: floor NUMBER &optional DIVISOR
  862.      This returns NUMBER, converted to an integer by rounding downward
  863.      (towards negative infinity).
  864.  
  865.      If DIVISOR is specified, NUMBER is divided by DIVISOR before the
  866.      floor is taken; this is the division operation that corresponds to
  867.      `mod'.  An `arith-error' results if DIVISOR is 0.
  868.  
  869.  - Function: ceiling NUMBER
  870.      This returns NUMBER, converted to an integer by rounding upward
  871.      (towards positive infinity).
  872.  
  873.  - Function: round NUMBER
  874.      This returns NUMBER, converted to an integer by rounding towards
  875.      the nearest integer.  Rounding a value equidistant between two
  876.      integers may choose the integer closer to zero, or it may prefer
  877.      an even integer, depending on your machine.
  878.  
  879. 
  880. File: lispref.info,  Node: Arithmetic Operations,  Next: Rounding Operations,  Prev: Numeric Conversions,  Up: Numbers
  881.  
  882. Arithmetic Operations
  883. =====================
  884.  
  885.    XEmacs Lisp provides the traditional four arithmetic operations:
  886. addition, subtraction, multiplication, and division.  Remainder and
  887. modulus functions supplement the division functions.  The functions to
  888. add or subtract 1 are provided because they are traditional in Lisp and
  889. commonly used.
  890.  
  891.    All of these functions except `%' return a floating point value if
  892. any argument is floating.
  893.  
  894.    It is important to note that in XEmacs Lisp, arithmetic functions do
  895. not check for overflow.  Thus `(1+ 134217727)' may evaluate to
  896. -134217728, depending on your hardware.
  897.  
  898.  - Function: 1+ NUMBER-OR-MARKER
  899.      This function returns NUMBER-OR-MARKER plus 1.  For example,
  900.  
  901.           (setq foo 4)
  902.                => 4
  903.           (1+ foo)
  904.                => 5
  905.  
  906.      This function is not analogous to the C operator `++'--it does not
  907.      increment a variable.  It just computes a sum.  Thus, if we
  908.      continue,
  909.  
  910.           foo
  911.                => 4
  912.  
  913.      If you want to increment the variable, you must use `setq', like
  914.      this:
  915.  
  916.           (setq foo (1+ foo))
  917.                => 5
  918.  
  919.      Now that the `cl' package is always available from lisp code, a
  920.      more convenient and natural way to increment a variable is
  921.      `(incf foo)'.
  922.  
  923.  - Function: 1- NUMBER-OR-MARKER
  924.      This function returns NUMBER-OR-MARKER minus 1.
  925.  
  926.  - Function: abs NUMBER
  927.      This returns the absolute value of NUMBER.
  928.  
  929.  - Function: + &rest NUMBERS-OR-MARKERS
  930.      This function adds its arguments together.  When given no
  931.      arguments, `+' returns 0.
  932.  
  933.           (+)
  934.                => 0
  935.           (+ 1)
  936.                => 1
  937.           (+ 1 2 3 4)
  938.                => 10
  939.  
  940.  - Function: - &optional NUMBER-OR-MARKER &rest OTHER-NUMBERS-OR-MARKERS
  941.      The `-' function serves two purposes: negation and subtraction.
  942.      When `-' has a single argument, the value is the negative of the
  943.      argument.  When there are multiple arguments, `-' subtracts each of
  944.      the OTHER-NUMBERS-OR-MARKERS from NUMBER-OR-MARKER, cumulatively.
  945.      If there are no arguments, the result is 0.
  946.  
  947.           (- 10 1 2 3 4)
  948.                => 0
  949.           (- 10)
  950.                => -10
  951.           (-)
  952.                => 0
  953.  
  954.  - Function: * &rest NUMBERS-OR-MARKERS
  955.      This function multiplies its arguments together, and returns the
  956.      product.  When given no arguments, `*' returns 1.
  957.  
  958.           (*)
  959.                => 1
  960.           (* 1)
  961.                => 1
  962.           (* 1 2 3 4)
  963.                => 24
  964.  
  965.  - Function: / DIVIDEND DIVISOR &rest DIVISORS
  966.      This function divides DIVIDEND by DIVISOR and returns the
  967.      quotient.  If there are additional arguments DIVISORS, then it
  968.      divides DIVIDEND by each divisor in turn.  Each argument may be a
  969.      number or a marker.
  970.  
  971.      If all the arguments are integers, then the result is an integer
  972.      too.  This means the result has to be rounded.  On most machines,
  973.      the result is rounded towards zero after each division, but some
  974.      machines may round differently with negative arguments.  This is
  975.      because the Lisp function `/' is implemented using the C division
  976.      operator, which also permits machine-dependent rounding.  As a
  977.      practical matter, all known machines round in the standard fashion.
  978.  
  979.      If you divide by 0, an `arith-error' error is signaled.  (*Note
  980.      Errors::.)
  981.  
  982.           (/ 6 2)
  983.                => 3
  984.           (/ 5 2)
  985.                => 2
  986.           (/ 25 3 2)
  987.                => 4
  988.           (/ -17 6)
  989.                => -2
  990.  
  991.      The result of `(/ -17 6)' could in principle be -3 on some
  992.      machines.
  993.  
  994.  - Function: % DIVIDEND DIVISOR
  995.      This function returns the integer remainder after division of
  996.      DIVIDEND by DIVISOR.  The arguments must be integers or markers.
  997.  
  998.      For negative arguments, the remainder is in principle
  999.      machine-dependent since the quotient is; but in practice, all
  1000.      known machines behave alike.
  1001.  
  1002.      An `arith-error' results if DIVISOR is 0.
  1003.  
  1004.           (% 9 4)
  1005.                => 1
  1006.           (% -9 4)
  1007.                => -1
  1008.           (% 9 -4)
  1009.                => 1
  1010.           (% -9 -4)
  1011.                => -1
  1012.  
  1013.      For any two integers DIVIDEND and DIVISOR,
  1014.  
  1015.           (+ (% DIVIDEND DIVISOR)
  1016.              (* (/ DIVIDEND DIVISOR) DIVISOR))
  1017.  
  1018.      always equals DIVIDEND.
  1019.  
  1020.  - Function: mod DIVIDEND DIVISOR
  1021.      This function returns the value of DIVIDEND modulo DIVISOR; in
  1022.      other words, the remainder after division of DIVIDEND by DIVISOR,
  1023.      but with the same sign as DIVISOR.  The arguments must be numbers
  1024.      or markers.
  1025.  
  1026.      Unlike `%', `mod' returns a well-defined result for negative
  1027.      arguments.  It also permits floating point arguments; it rounds the
  1028.      quotient downward (towards minus infinity) to an integer, and uses
  1029.      that quotient to compute the remainder.
  1030.  
  1031.      An `arith-error' results if DIVISOR is 0.
  1032.  
  1033.           (mod 9 4)
  1034.                => 1
  1035.           (mod -9 4)
  1036.                => 3
  1037.           (mod 9 -4)
  1038.                => -3
  1039.           (mod -9 -4)
  1040.                => -1
  1041.           (mod 5.5 2.5)
  1042.                => .5
  1043.  
  1044.      For any two numbers DIVIDEND and DIVISOR,
  1045.  
  1046.           (+ (mod DIVIDEND DIVISOR)
  1047.              (* (floor DIVIDEND DIVISOR) DIVISOR))
  1048.  
  1049.      always equals DIVIDEND, subject to rounding error if either
  1050.      argument is floating point.  For `floor', see *Note Numeric
  1051.      Conversions::.
  1052.  
  1053. 
  1054. File: lispref.info,  Node: Rounding Operations,  Next: Bitwise Operations,  Prev: Arithmetic Operations,  Up: Numbers
  1055.  
  1056. Rounding Operations
  1057. ===================
  1058.  
  1059.    The functions `ffloor', `fceiling', `fround' and `ftruncate' take a
  1060. floating point argument and return a floating point result whose value
  1061. is a nearby integer.  `ffloor' returns the nearest integer below;
  1062. `fceiling', the nearest integer above; `ftruncate', the nearest integer
  1063. in the direction towards zero; `fround', the nearest integer.
  1064.  
  1065.  - Function: ffloor FLOAT
  1066.      This function rounds FLOAT to the next lower integral value, and
  1067.      returns that value as a floating point number.
  1068.  
  1069.  - Function: fceiling FLOAT
  1070.      This function rounds FLOAT to the next higher integral value, and
  1071.      returns that value as a floating point number.
  1072.  
  1073.  - Function: ftruncate FLOAT
  1074.      This function rounds FLOAT towards zero to an integral value, and
  1075.      returns that value as a floating point number.
  1076.  
  1077.  - Function: fround FLOAT
  1078.      This function rounds FLOAT to the nearest integral value, and
  1079.      returns that value as a floating point number.
  1080.  
  1081. 
  1082. File: lispref.info,  Node: Bitwise Operations,  Next: Math Functions,  Prev: Rounding Operations,  Up: Numbers
  1083.  
  1084. Bitwise Operations on Integers
  1085. ==============================
  1086.  
  1087.    In a computer, an integer is represented as a binary number, a
  1088. sequence of "bits" (digits which are either zero or one).  A bitwise
  1089. operation acts on the individual bits of such a sequence.  For example,
  1090. "shifting" moves the whole sequence left or right one or more places,
  1091. reproducing the same pattern "moved over".
  1092.  
  1093.    The bitwise operations in XEmacs Lisp apply only to integers.
  1094.  
  1095.  - Function: lsh INTEGER1 COUNT
  1096.      `lsh', which is an abbreviation for "logical shift", shifts the
  1097.      bits in INTEGER1 to the left COUNT places, or to the right if
  1098.      COUNT is negative, bringing zeros into the vacated bits.  If COUNT
  1099.      is negative, `lsh' shifts zeros into the leftmost
  1100.      (most-significant) bit, producing a positive result even if
  1101.      INTEGER1 is negative.  Contrast this with `ash', below.
  1102.  
  1103.      Here are two examples of `lsh', shifting a pattern of bits one
  1104.      place to the left.  We show only the low-order eight bits of the
  1105.      binary pattern; the rest are all zero.
  1106.  
  1107.           (lsh 5 1)
  1108.                => 10
  1109.           ;; Decimal 5 becomes decimal 10.
  1110.           00000101 => 00001010
  1111.           
  1112.           (lsh 7 1)
  1113.                => 14
  1114.           ;; Decimal 7 becomes decimal 14.
  1115.           00000111 => 00001110
  1116.  
  1117.      As the examples illustrate, shifting the pattern of bits one place
  1118.      to the left produces a number that is twice the value of the
  1119.      previous number.
  1120.  
  1121.      Shifting a pattern of bits two places to the left produces results
  1122.      like this (with 8-bit binary numbers):
  1123.  
  1124.           (lsh 3 2)
  1125.                => 12
  1126.           ;; Decimal 3 becomes decimal 12.
  1127.           00000011 => 00001100
  1128.  
  1129.      On the other hand, shifting one place to the right looks like this:
  1130.  
  1131.           (lsh 6 -1)
  1132.                => 3
  1133.           ;; Decimal 6 becomes decimal 3.
  1134.           00000110 => 00000011
  1135.           
  1136.           (lsh 5 -1)
  1137.                => 2
  1138.           ;; Decimal 5 becomes decimal 2.
  1139.           00000101 => 00000010
  1140.  
  1141.      As the example illustrates, shifting one place to the right
  1142.      divides the value of a positive integer by two, rounding downward.
  1143.  
  1144.      The function `lsh', like all XEmacs Lisp arithmetic functions, does
  1145.      not check for overflow, so shifting left can discard significant
  1146.      bits and change the sign of the number.  For example, left shifting
  1147.      134,217,727 produces -2 on a 28-bit machine:
  1148.  
  1149.           (lsh 134217727 1)          ; left shift
  1150.                => -2
  1151.  
  1152.      In binary, in the 28-bit implementation, the argument looks like
  1153.      this:
  1154.  
  1155.           ;; Decimal 134,217,727
  1156.           0111  1111 1111  1111 1111  1111 1111
  1157.  
  1158.      which becomes the following when left shifted:
  1159.  
  1160.           ;; Decimal -2
  1161.           1111  1111 1111  1111 1111  1111 1110
  1162.  
  1163.  - Function: ash INTEGER1 COUNT
  1164.      `ash' ("arithmetic shift") shifts the bits in INTEGER1 to the left
  1165.      COUNT places, or to the right if COUNT is negative.
  1166.  
  1167.      `ash' gives the same results as `lsh' except when INTEGER1 and
  1168.      COUNT are both negative.  In that case, `ash' puts ones in the
  1169.      empty bit positions on the left, while `lsh' puts zeros in those
  1170.      bit positions.
  1171.  
  1172.      Thus, with `ash', shifting the pattern of bits one place to the
  1173.      right looks like this:
  1174.  
  1175.           (ash -6 -1) => -3
  1176.           ;; Decimal -6 becomes decimal -3.
  1177.           1111  1111 1111  1111 1111  1111 1010
  1178.                =>
  1179.           1111  1111 1111  1111 1111  1111 1101
  1180.  
  1181.      In contrast, shifting the pattern of bits one place to the right
  1182.      with `lsh' looks like this:
  1183.  
  1184.           (lsh -6 -1) => 134217725
  1185.           ;; Decimal -6 becomes decimal 134,217,725.
  1186.           1111  1111 1111  1111 1111  1111 1010
  1187.                =>
  1188.           0111  1111 1111  1111 1111  1111 1101
  1189.  
  1190.      Here are other examples:
  1191.  
  1192.           ;               28-bit binary values
  1193.           
  1194.           (lsh 5 2)          ;   5  =  0000  0000 0000  0000 0000  0000 0101
  1195.                => 20         ;      =  0000  0000 0000  0000 0000  0001 0100
  1196.  
  1197.           (ash 5 2)
  1198.                => 20
  1199.           (lsh -5 2)         ;  -5  =  1111  1111 1111  1111 1111  1111 1011
  1200.                => -20        ;      =  1111  1111 1111  1111 1111  1110 1100
  1201.           (ash -5 2)
  1202.                => -20
  1203.  
  1204.           (lsh 5 -2)         ;   5  =  0000  0000 0000  0000 0000  0000 0101
  1205.                => 1          ;      =  0000  0000 0000  0000 0000  0000 0001
  1206.  
  1207.           (ash 5 -2)
  1208.                => 1
  1209.  
  1210.           (lsh -5 -2)        ;  -5  =  1111  1111 1111  1111 1111  1111 1011
  1211.                => 4194302    ;      =  0011  1111 1111  1111 1111  1111 1110
  1212.  
  1213.           (ash -5 -2)        ;  -5  =  1111  1111 1111  1111 1111  1111 1011
  1214.                => -2         ;      =  1111  1111 1111  1111 1111  1111 1110
  1215.  
  1216.  - Function: logand &rest INTS-OR-MARKERS
  1217.      This function returns the "logical and" of the arguments: the Nth
  1218.      bit is set in the result if, and only if, the Nth bit is set in
  1219.      all the arguments.  ("Set" means that the value of the bit is 1
  1220.      rather than 0.)
  1221.  
  1222.      For example, using 4-bit binary numbers, the "logical and" of 13
  1223.      and 12 is 12: 1101 combined with 1100 produces 1100.  In both the
  1224.      binary numbers, the leftmost two bits are set (i.e., they are
  1225.      1's), so the leftmost two bits of the returned value are set.
  1226.      However, for the rightmost two bits, each is zero in at least one
  1227.      of the arguments, so the rightmost two bits of the returned value
  1228.      are 0's.
  1229.  
  1230.      Therefore,
  1231.  
  1232.           (logand 13 12)
  1233.                => 12
  1234.  
  1235.      If `logand' is not passed any argument, it returns a value of -1.
  1236.      This number is an identity element for `logand' because its binary
  1237.      representation consists entirely of ones.  If `logand' is passed
  1238.      just one argument, it returns that argument.
  1239.  
  1240.           ;                28-bit binary values
  1241.           
  1242.           (logand 14 13)     ; 14  =  0000  0000 0000  0000 0000  0000 1110
  1243.                              ; 13  =  0000  0000 0000  0000 0000  0000 1101
  1244.                => 12         ; 12  =  0000  0000 0000  0000 0000  0000 1100
  1245.  
  1246.           (logand 14 13 4)   ; 14  =  0000  0000 0000  0000 0000  0000 1110
  1247.                              ; 13  =  0000  0000 0000  0000 0000  0000 1101
  1248.                              ;  4  =  0000  0000 0000  0000 0000  0000 0100
  1249.                => 4          ;  4  =  0000  0000 0000  0000 0000  0000 0100
  1250.  
  1251.           (logand)
  1252.                => -1         ; -1  =  1111  1111 1111  1111 1111  1111 1111
  1253.  
  1254.  - Function: logior &rest INTS-OR-MARKERS
  1255.      This function returns the "inclusive or" of its arguments: the Nth
  1256.      bit is set in the result if, and only if, the Nth bit is set in at
  1257.      least one of the arguments.  If there are no arguments, the result
  1258.      is zero, which is an identity element for this operation.  If
  1259.      `logior' is passed just one argument, it returns that argument.
  1260.  
  1261.           ;               28-bit binary values
  1262.           
  1263.           (logior 12 5)      ; 12  =  0000  0000 0000  0000 0000  0000 1100
  1264.                              ;  5  =  0000  0000 0000  0000 0000  0000 0101
  1265.                => 13         ; 13  =  0000  0000 0000  0000 0000  0000 1101
  1266.  
  1267.           (logior 12 5 7)    ; 12  =  0000  0000 0000  0000 0000  0000 1100
  1268.                              ;  5  =  0000  0000 0000  0000 0000  0000 0101
  1269.                              ;  7  =  0000  0000 0000  0000 0000  0000 0111
  1270.                => 15         ; 15  =  0000  0000 0000  0000 0000  0000 1111
  1271.  
  1272.  - Function: logxor &rest INTS-OR-MARKERS
  1273.      This function returns the "exclusive or" of its arguments: the Nth
  1274.      bit is set in the result if, and only if, the Nth bit is set in an
  1275.      odd number of the arguments.  If there are no arguments, the
  1276.      result is 0, which is an identity element for this operation.  If
  1277.      `logxor' is passed just one argument, it returns that argument.
  1278.  
  1279.           ;               28-bit binary values
  1280.           
  1281.           (logxor 12 5)      ; 12  =  0000  0000 0000  0000 0000  0000 1100
  1282.                              ;  5  =  0000  0000 0000  0000 0000  0000 0101
  1283.                => 9          ;  9  =  0000  0000 0000  0000 0000  0000 1001
  1284.  
  1285.           (logxor 12 5 7)    ; 12  =  0000  0000 0000  0000 0000  0000 1100
  1286.                              ;  5  =  0000  0000 0000  0000 0000  0000 0101
  1287.                              ;  7  =  0000  0000 0000  0000 0000  0000 0111
  1288.                => 14         ; 14  =  0000  0000 0000  0000 0000  0000 1110
  1289.  
  1290.  - Function: lognot INTEGER
  1291.      This function returns the logical complement of its argument: the
  1292.      Nth bit is one in the result if, and only if, the Nth bit is zero
  1293.      in INTEGER, and vice-versa.
  1294.  
  1295.           (lognot 5)
  1296.                => -6
  1297.           ;;  5  =  0000  0000 0000  0000 0000  0000 0101
  1298.           ;; becomes
  1299.           ;; -6  =  1111  1111 1111  1111 1111  1111 1010
  1300.  
  1301. 
  1302. File: lispref.info,  Node: Math Functions,  Next: Random Numbers,  Prev: Bitwise Operations,  Up: Numbers
  1303.  
  1304. Standard Mathematical Functions
  1305. ===============================
  1306.  
  1307.    These mathematical functions are available if floating point is
  1308. supported (which is the normal state of affairs).  They allow integers
  1309. as well as floating point numbers as arguments.
  1310.  
  1311.  - Function: sin ARG
  1312.  - Function: cos ARG
  1313.  - Function: tan ARG
  1314.      These are the ordinary trigonometric functions, with argument
  1315.      measured in radians.
  1316.  
  1317.  - Function: asin ARG
  1318.      The value of `(asin ARG)' is a number between -pi/2 and pi/2
  1319.      (inclusive) whose sine is ARG; if, however, ARG is out of range
  1320.      (outside [-1, 1]), then the result is a NaN.
  1321.  
  1322.  - Function: acos ARG
  1323.      The value of `(acos ARG)' is a number between 0 and pi (inclusive)
  1324.      whose cosine is ARG; if, however, ARG is out of range (outside
  1325.      [-1, 1]), then the result is a NaN.
  1326.  
  1327.  - Function: atan ARG
  1328.      The value of `(atan ARG)' is a number between -pi/2 and pi/2
  1329.      (exclusive) whose tangent is ARG.
  1330.  
  1331.  - Function: sinh ARG
  1332.  - Function: cosh ARG
  1333.  - Function: tanh ARG
  1334.      These are the ordinary hyperbolic trigonometric functions.
  1335.  
  1336.  - Function: asinh ARG
  1337.  - Function: acosh ARG
  1338.  - Function: atanh ARG
  1339.      These are the inverse hyperbolic trigonometric functions.
  1340.  
  1341.  - Function: exp ARG
  1342.      This is the exponential function; it returns e to the power ARG.
  1343.      e is a fundamental mathematical constant also called the base of
  1344.      natural logarithms.
  1345.  
  1346.  - Function: log ARG &optional BASE
  1347.      This function returns the logarithm of ARG, with base BASE.  If
  1348.      you don't specify BASE, the base E is used.  If ARG is negative,
  1349.      the result is a NaN.
  1350.  
  1351.  - Function: log10 ARG
  1352.      This function returns the logarithm of ARG, with base 10.  If ARG
  1353.      is negative, the result is a NaN.  `(log10 X)' == `(log X 10)', at
  1354.      least approximately.
  1355.  
  1356.  - Function: expt X Y
  1357.      This function returns X raised to power Y.  If both arguments are
  1358.      integers and Y is positive, the result is an integer; in this
  1359.      case, it is truncated to fit the range of possible integer values.
  1360.  
  1361.  - Function: sqrt ARG
  1362.      This returns the square root of ARG.  If ARG is negative, the
  1363.      value is a NaN.
  1364.  
  1365.  - Function: cube-root ARG
  1366.      This returns the cube root of ARG.
  1367.  
  1368. 
  1369. File: lispref.info,  Node: Random Numbers,  Prev: Math Functions,  Up: Numbers
  1370.  
  1371. Random Numbers
  1372. ==============
  1373.  
  1374.    A deterministic computer program cannot generate true random numbers.
  1375. For most purposes, "pseudo-random numbers" suffice.  A series of
  1376. pseudo-random numbers is generated in a deterministic fashion.  The
  1377. numbers are not truly random, but they have certain properties that
  1378. mimic a random series.  For example, all possible values occur equally
  1379. often in a pseudo-random series.
  1380.  
  1381.    In XEmacs, pseudo-random numbers are generated from a "seed" number.
  1382. Starting from any given seed, the `random' function always generates
  1383. the same sequence of numbers.  XEmacs always starts with the same seed
  1384. value, so the sequence of values of `random' is actually the same in
  1385. each XEmacs run!  For example, in one operating system, the first call
  1386. to `(random)' after you start XEmacs always returns -1457731, and the
  1387. second one always returns -7692030.  This repeatability is helpful for
  1388. debugging.
  1389.  
  1390.    If you want truly unpredictable random numbers, execute `(random
  1391. t)'.  This chooses a new seed based on the current time of day and on
  1392. XEmacs's process ID number.
  1393.  
  1394.  - Function: random &optional LIMIT
  1395.      This function returns a pseudo-random integer.  Repeated calls
  1396.      return a series of pseudo-random integers.
  1397.  
  1398.      If LIMIT is a positive integer, the value is chosen to be
  1399.      nonnegative and less than LIMIT.
  1400.  
  1401.      If LIMIT is `t', it means to choose a new seed based on the
  1402.      current time of day and on XEmacs's process ID number.
  1403.  
  1404.      On some machines, any integer representable in Lisp may be the
  1405.      result of `random'.  On other machines, the result can never be
  1406.      larger than a certain maximum or less than a certain (negative)
  1407.      minimum.
  1408.  
  1409. 
  1410. File: lispref.info,  Node: Strings and Characters,  Next: Lists,  Prev: Numbers,  Up: Top
  1411.  
  1412. Strings and Characters
  1413. **********************
  1414.  
  1415.    A string in XEmacs Lisp is an array that contains an ordered sequence
  1416. of characters.  Strings are used as names of symbols, buffers, and
  1417. files, to send messages to users, to hold text being copied between
  1418. buffers, and for many other purposes.  Because strings are so important,
  1419. XEmacs Lisp has many functions expressly for manipulating them.  XEmacs
  1420. Lisp programs use strings more often than individual characters.
  1421.  
  1422. * Menu:
  1423.  
  1424. * Basics: String Basics.      Basic properties of strings and characters.
  1425. * Predicates for Strings::    Testing whether an object is a string or char.
  1426. * Creating Strings::          Functions to allocate new strings.
  1427. * Predicates for Characters:: Testing whether an object is a character.
  1428. * Character Codes::           Each character has an equivalent integer.
  1429. * Text Comparison::           Comparing characters or strings.
  1430. * String Conversion::         Converting characters or strings and vice versa.
  1431. * Modifying Strings::          Changing characters in a string.
  1432. * String Properties::          Additional information attached to strings.
  1433. * Formatting Strings::        `format': XEmacs's analog of `printf'.
  1434. * Character Case::            Case conversion functions.
  1435. * Case Tables::              Customizing case conversion.
  1436. * Char Tables::               Mapping from characters to Lisp objects.
  1437.  
  1438.